package com.ktjiaoyu.crm.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ktjiaoyu.crm.pojo.Right;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.Set;

public interface RightMapper extends BaseMapper<Right> {

    /**
     * 根据角色ID查询角色拥有权限
     * @param roleId
     * @return
     */
    @Select("SELECT r.rf_right_code FROM `sys_role_right` r " +
            "        left join sys_role s on r.rf_role_id=s.role_id " +
            "        left join  sys_right ri on r.rf_right_code=ri.right_code " +
            "        where s.role_id=#{roleId}")
    Set<String> findRightsByRoleName(@Param("roleId") Long roleId);
}
